<?php
class FrameworkBase {

	/**
	 * class search paths
	 * @var array
	 */
	public $includePaths = array();


	public function __construct () {
		/* default search path */
		array_push($this->includePaths, SERVER_ROOT_PATH . '/lib', SERVER_ROOT_PATH . '/models', SERVER_ROOT_PATH . '/classes');
		/* register autoload */
		if (method_exists($this, '__autoload')) {
			spl_autoload_register(array($this, '__autoload'));
		}
	}
	
	public function __autoload ($classname) {
		foreach ($this->includePaths as $path) {
			$filename = $path . DIRECTORY_SEPARATOR . ucfirst(str_replace('_', DIRECTORY_SEPARATOR, $classname)) . '.class.php';
			if (file_exists($filename)) {
				require_once $filename;
				return true;
			}
		}
	}

	public function setIncludePath ($path) {
		if (is_array($path) && count($path) > 0) {
			$this->includePaths = $path;
		}
		return true;
	}

	public function pushIncludePath ($path) {
		array_push($this->includePaths, $path);
		return true;
	}

	public function getIncludePath () {
		return $this->includePaths;
	}
}